from selenium.webdriver.common.by import By

from common.base import Base


class IndexPage(Base):
    def search_username(self):
        return self.find_element_text((By.XPATH, "//font[@id='ECS_MEMBERZONE']/font/font"))

    def logout(self):
        self.click((By.LINK_TEXT, "退出"))

    # 购物车文本
    def cart_num(self):
        return self.find_element_text((By.XPATH, '/html/body/div[1]/div/div[2]/div[2]/a'))

    # 查看收藏夹商品名称
    def favorites_name(self):
        self.click((By.XPATH, '//*[@id="ECS_MEMBERZONE"]/font/a[1]'))
        self.click((By.XPATH, '/html/body/div[6]/div[1]/div/div/div/div/a[5]'))
        self.click((By.XPATH, '/html/body/div[1]/div/div[2]/div[2]/a'))
        return self.find_element_text((By.LINK_TEXT, '自拍杆'))